package cn.tedu.net.collection.game;

import java.util.Random;

//本类用于热武器AK47的封装
public class AK47 {
    int bullets = 100;
    public void load(){
        bullets=100;
        System.out.println("弹夹装满~");
    }
    public void fire(){
        if(bullets==0){
            System.out.println("没有子弹了~");
            return;
        }
        Random random = new Random();
        int r = random.nextInt(10);
        if (r>bullets) {
            r=bullets;
        }
        bullets=bullets-r;
        for (int i = 0; i < r; i++) {
            System.out.print("突!");
        }
        System.out.println();
        if(bullets==0){
            System.out.println("弹夹空了,快换子弹");
        }
    }
}